let vue=new Vue({
   el:'.page-content',
    data:{
        sta:{},
       result:{},
        // statute:{
        //    type:''
        // },
        type:"",
        ueditorIndexConfig:{
           UEDITOR_HOME_URL:'static/ueditor/',
            serverUrl: 'doUeditor'
        }
    },
    methods:{
       select:function (pageNum,pageSize) {
           axios({
               url:'statute/select',
                method:'post',
               data:{"type":this.type,
                   "pageNum":pageNum,
                   "pageSize":pageSize}
           }).then(rs=>{
               this.result=rs.data.obj
           }).catch(error=>{
               layer.msg(error.message)
           })
       },
        selectAll:function (pageNum,pageSize) {
           this.type='';
            axios({
                url:`statute/select`,
                method:'post',
                data:{'type':this.type,
                        'pageNum':pageNum,
                        'pageSize':pageSize
                }
            }).then(rs=>{
                this.result=rs.data.obj
            }).catch(error=>{
                layer.msg(error.message)
            })
        },
        deleteOne:function (id) {
            axios({
                url:`statute/deleteOne/${id}`
            }).then(rs=>{
                layer.msg("删除成功");
                this.select(1,4)
            })
        },
        toUpdate:function (uid) {
           layer.id=uid;
           layer.message='';
            layer.open({
                type:2,
                title:false,
                area:['80%','80%'],
                content:"statute/toUpdate",
                end:()=>{
                    if (layer.message!=''){
                    layer.msg("更新成功")
                    }
                }
            })
        },
        insertOne:function () {
            axios({
                url:'statute/insertOne',
                method:'post',
                data:this.sta
            }).then(rs=>{
                if (rs.data.success) {
                    this.sta={};
                    this.selectAll(1,5);
                    layer.msg("添加成功")
                }
            }).catch(error=>{
                layer.msg(error.message)
            })
        }
    },
    created:function () {
        this.select(1,4)
    },
    mounted:function(){  //挂载el后  创建日期插件对象
        jeDate({
            dateCell: '#indate',
            format: 'YYYY-MM-DD hh:mm:ss',
            zIndex: 999999999,   //图层
            okfun:val => {//点击确定后的回调
                this.sta.createDate=val;
            },
            choosefun:val => {//选中日期后的回调
                this.sta.createDate=val;
            },
        });
    },
    components:{
        VueUeditorWrap
    }
});